package com.yunkeji.common.enums.app;

import com.yunkeji.common.exception.AppServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/** 语音审核状态 */
@Getter
@AllArgsConstructor
public enum VoiceCheckStatus {
    未处理(1),
    忽略(2),
    违规(3);
    private Integer code;

    public static VoiceCheckStatus getByCode(Integer code) {
        VoiceCheckStatus[] values = VoiceCheckStatus.values();
        Optional<VoiceCheckStatus> first =
                Arrays.stream(values).filter(item -> item.getCode().equals(code)).findFirst();
        if (first.isPresent()) {
            return first.get();
        } else {
            throw AppServiceException.paramException("审核状态参数异常");
        }
    }
}
